package org.wmq.shopmanager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.wmq.commonutil.result.Result;
import org.wmq.shopmanager.service.ProductSpecService;
import org.wmq.shopmodel.Entity.product.ProductSpec;

@RestController
@RequestMapping("/admin/product/product-spec")
@RequiredArgsConstructor
public class ProductSpecController {
    private final ProductSpecService productSpecService;

    @GetMapping("/{pageNo}/{pageSize}")
    public Result<IPage<ProductSpec>> getProdectSpecPageItem(@PathVariable Long pageNo, @PathVariable Long pageSize){
        return Result.success(this.productSpecService.getPageItem(pageNo,pageSize));
    }

    @PostMapping
    public Result<Void> saveProductSpec(@RequestBody ProductSpec productSpec){
        this.productSpecService.save(productSpec);
        return Result.success();
    }
    @DeleteMapping("/{id}")
    public Result<Void> removeProductSpecById(@PathVariable Long id){
        this.productSpecService.removeById(id);
        return Result.success();
    }
    @PutMapping
    public Result<Void> updateProductSpecById(@RequestBody ProductSpec productSpec){
        this.productSpecService.updateById(productSpec);
        return Result.success();
    }

}
